package game.view.menu
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	import game.UIComponent.FoodTypeSquare;
	import game.UIComponent.ScrollBar;
	import game.common.CustomBitmap;
	import game.managers.LanguageManager;
	import game.utils.Utils;
	
	public class FirstFoodType extends Sprite
	{
		private var _bg:CustomBitmap;
		private var _lineBg:CustomBitmap;
		private var _topTips:TextField;
		
		private var _foodsquare1:FoodTypeSquare;
		private var _foodsquare2:FoodTypeSquare;
		private var _foodsquare3:FoodTypeSquare;
		private var _foodsquare4:FoodTypeSquare;
		
		private var _scrollBar:ScrollBar;
		public function FirstFoodType()
		{
			init();
		}
		
		private function init():void
		{
			_bg=new CustomBitmap();
			_bg.source="tabBg";
			_bg.width=450;
			_bg.height=280;
			addChild(_bg);
			
			_lineBg=new CustomBitmap();
			_lineBg.source="lineBg";
			_lineBg.x=_bg.x + 10;
			_lineBg.y=_bg.y + 10;
			addChild(_lineBg);
			
			_topTips=Utils.getTextField(LanguageManager.getWord("menu.toptips1"),12);
			_topTips.width=_topTips.textWidth;
			_topTips.height=_topTips.textHeight + 5;
			_topTips.x=_lineBg.x +50;
			_topTips.y=_lineBg.y + 2;
			addChild(_topTips);
			
			_foodsquare1=new FoodTypeSquare("yuecai1",LanguageManager.getWord("first.qiezi"),1,2,1);
			_foodsquare1.x=_lineBg.x;
			_foodsquare1.y=_lineBg.y + _lineBg.height + 5;
			addChild(_foodsquare1);

			_foodsquare2=new FoodTypeSquare("yuecai2",LanguageManager.getWord("first.luobo"),2,4,2);
			_foodsquare2.x=_foodsquare1.x + _foodsquare1.width - 35;
			_foodsquare2.y=_foodsquare1.y;
			addChild(_foodsquare2);
			
			_foodsquare3=new FoodTypeSquare("yuecai3",LanguageManager.getWord("first.huakai"),2.2,6,3);
			_foodsquare3.x=_lineBg.x;
			_foodsquare3.y=_foodsquare1.y + _foodsquare1.height - 40;
			addChild(_foodsquare3);
			
			_foodsquare4=new FoodTypeSquare("yuecai4",LanguageManager.getWord("first.huangpu"),3.4,8,4);
			_foodsquare4.x=_foodsquare2.x;
			_foodsquare4.y=_foodsquare2.y + _foodsquare2.height -40;
			addChild(_foodsquare4);
			
			_scrollBar=new ScrollBar();
			_scrollBar.x=_foodsquare2.x + _foodsquare2.width - 40;
			_scrollBar.y=_foodsquare2.y;
			addChild(_scrollBar);
			
		}
		
		/**
		 * 将4个菜式格子的buyBtn检查是否和选定的3个食材吻合
		 * */
		public function buyBtnEnabled():void
		{
			_foodsquare1.checkBuyBtn();
			_foodsquare2.checkBuyBtn();
			_foodsquare3.checkBuyBtn();
			_foodsquare4.checkBuyBtn();		
		}
	}
}